#include <istream>
#include <pthread.h>
using namespace std;
#include <string>
typedef void (*callback_t)();
static int num = 1;
class Thread
{
private:
    pthread_t tid_;
    std::string name_;
    uint64_t start_timestamp_;
    bool isrunning_;
    callback_t cb_;

public:
    Thread(callback_t cb) : tid_(0), name_(""), start_timestamp_(0), isrunning_(false), cb_(cb)
    {
    }
    string name()
    {
        return name_;
    }
    uint64_t StartTimestamp()
    {
        return start_timestamp_;
    }
    static void *Routin(void *args)
    {
        Thread *th = static_cast<Thread *>(args);

        th->Entery();
        return NULL;
    }
    void Entery()
    {
        cb_();
    }
    void Run()
    {
        pthread_create(&tid_, NULL, Routin, this);
        name_ = "thread-" + std::to_string(num++);
        start_timestamp_ = time(NULL);
        isrunning_ = true;
    }
    void Join()
    {
        pthread_join(tid_, NULL);
        isrunning_ = false;
    }
};
